#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2024/12/30 22:43
# @Author : George
import asyncio
"""
create_task本质上就是获取事件循环，创建task对象
    loop = events.get_running_loop()
    return loop.create_task(coro)

"""
async def net(name):
    print(name,"进入IO")
    await asyncio.sleep(3)
    print(name,"结束IO")
    return 100

async def main(name):
    print(name,"start")
    task_list = [asyncio.create_task(net("任务1")),asyncio.create_task(net("任务2"))]
    # done 里面存放的是已经完成的task任务
    done,pending = await asyncio.wait(task_list) # asyncio.wait 等待任务列表里面的任务全部执行完毕
    for task in done:
        print(task) # <Task finished coro=<net() done, defined at D:\PythonData\pythonProject\reptile\异步IO\asyncio_task_list.py:7> result=100>
    print("end")

asyncio.run(main("我的任务"))